<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">

    <ui:define name="title">发票记录</ui:define>
    <ui:define name="content">
        <h:form id="billForm">
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false"
                      draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="statisticRecordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         update="@form"/>
                        <p:commandButton value="重置" actionListener="#{xhhSettlementBillListBean.onReset()}"
                                         icon="fa fa-refresh"
                                         process="@this" update="@form"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         ajax="false">
                            <p:dataExporter type="xls" target="statisticRecordDataTable" fileName="开票记录"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>查询条件</h1>
                        <p:panelGrid columns="4" layout="grid"
                                     columnClasses="ui-grid-col-1,ui-grid-col-5,ui-grid-col-1,ui-grid-col-5"
                                     styleClass="ui-panelgrid-blank"
                                     style="border:0px none; background-color:transparent;text-align:center;">
                            <p:outputLabel value="主体名称"/>
                            <p:selectOneMenu id="productId" value="#{xhhSettlementBillListBean.$.companyId}"
                                             filter="true" updateLabel="true"
                                             filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                              noSelectionOption="true"/>
                                <f:selectItems value="#{xhhSettlementBillListBean.companyList}"
                                               var="dic"
                                               itemLabel="#{dic.companyName}" itemValue="#{dic.id}"/>
                            </p:selectOneMenu>

                            <p:outputLabel value="创建日期"/>
                            <p:outputPanel>
                                <p:calendar
                                        id="startTime" styleClass="autoWidthCalendar"
                                        value="#{xhhSettlementBillListBean.$.startTime}"
                                        locale="#{constants:get('LOCALE')}"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"/>
                                <span>— </span>
                                <p:calendar
                                        id="endTime" styleClass="autoWidthCalendar"
                                        value="#{xhhSettlementBillListBean.$.endTime}"
                                        locale="#{constants:get('LOCALE')}"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"/>
                            </p:outputPanel>

                            <p:outputLabel value="开票状态"/>
                            <p:selectOneMenu id="billStatus" value="#{xhhSettlementBillListBean.$.billStatus}">
                                <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                              noSelectionOption="true"/>
                                <f:selectItem itemLabel="未开票" itemValue="0"/>
                                <f:selectItem itemLabel="财务专员审核中" itemValue="1"/>
                                <f:selectItem itemLabel="财务经理审核中" itemValue="2"/>
                                <f:selectItem itemLabel="已开票" itemValue="3"/>
                                <f:selectItem itemLabel="作废" itemValue="4"/>
                            </p:selectOneMenu>

                            <p:outputLabel value="创建人"/>
                            <p:inputText id="creator" value="#{xhhSettlementBillListBean.$.creator}"/>

                        </p:panelGrid>
                    </div>

                    <div class="ui-g-12 card">
                        <p:dataTable id="statisticRecordDataTable"
                                     style="width: 100%;text-align:center"
                                     var="record"
                                     value="#{xhhSettlementBillListBean.lazyDataModel}"
                                     rows="#{constants:get('ROWS')}"
                                     lazy="true"
                                     paginator="true"
                                     paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                     rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                     emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                     scrollable="true"
                                     scrollWidth="97%"
                                     reflow="true"
                                     selection=""
                                     resizableColumns="true">
                            <p:column headerText="操作" exportable="false">
                                <p:splitButton icon="fa fa-eye"
                                               process="@this"
                                               actionListener="#{xhhSettlementBillListBean.onSee(record.id)}">
                                    <f:setPropertyActionListener
                                            value="/views/settlementsystem/bill-list.xhtml"
                                            target="#{currentUserBean.back}"/>
                                    <p:menuitem value="上传凭证" icon="fa fa-plus"
                                                oncomplete="PF('billImage').show()"
                                                update=":billForm:bill-image-dialog"
                                                rendered="#{record.billStatus == 3}">
                                        <f:setPropertyActionListener
                                                value="#{record.id}"
                                                target="#{xhhSettlementBillListBean.billId}"/>
                                        <f:setPropertyActionListener
                                                value="#{record.billImageUrl}"
                                                target="#{xhhSettlementBillListBean.billImageUrl}"/>
                                    </p:menuitem>
                                </p:splitButton>
                            </p:column>
                            <p:column headerText="主体唯一id" style="width: 50px">
                                <h:outputText value="#{record.companyId}"/>
                            </p:column>
                            <p:column headerText="主体名称" style="width: 250px">
                                <h:outputText value="#{record.companyName}"/>
                            </p:column>
                            <p:column headerText="记录类型">
                                <h:outputText rendered="#{record.recordType==1}" value="预付"/>
                                <h:outputText rendered="#{record.recordType==2}" value="消耗"/>
                            </p:column>
                            <p:column headerText="发票内容" style="text-align:center;">
                                <h:outputText
                                        value="#{xhhSettlementBillListBean.translate(DictionaryCode.XHH_SETTLEMENT_BILLING_CONTENT,record.billContent)}"/>
                            </p:column>
                            <p:column headerText="发票类型" style="text-align:center;">
                                <h:outputText
                                        value="#{xhhSettlementBillListBean.translate(DictionaryCode.XHH_SETTLEMENT_BILL_TYPE,record.billType)}"/>
                            </p:column>
                            <p:column headerText="发票金额" style="text-align:center;">
                                <h:outputText
                                        value="#{record.billAmount}">
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="发票状态" style="text-align:center;">
                                <h:outputText value="未开票" rendered="#{record.billStatus==0}" style="color: red"/>
                                <h:outputText value="财务专员审核中" rendered="#{record.billStatus==1}"
                                              style="color: olivedrab"/>
                                <h:outputText value="财务经理审核中" rendered="#{record.billStatus==2}"
                                              style="color: olivedrab"/>
                                <h:outputText value="已开票" rendered="#{record.billStatus==3}" style="color: blue"/>
                                <h:outputText value="作废" rendered="#{record.billStatus==4}" style="color: orange"/>
                            </p:column>
                            <p:column headerText="创建人" style="text-align:center;">
                                <h:outputText value="#{record.creator}"/>
                            </p:column>
                            <p:column headerText="创建时间" style="text-align:center;">
                                <h:outputText value="#{record.createTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                        </p:dataTable>
                    </div>
                </div>
            </div>
            <ui:include src="bill-info-dialog.xhtml"/>
            <ui:include src="bill-image-dialog.xhtml"/>
        </h:form>
    </ui:define>
</ui:composition>